package com.ktgj.customer.service.impl;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.ktgj.common.core.constant.CustomerConstants;
import com.ktgj.common.core.utils.DateUtils;
import com.ktgj.common.core.utils.helper.StringHelper;
import com.ktgj.common.redis.service.RedisService;
import com.ktgj.customer.domain.*;
import com.ktgj.customer.domain.dto.CustomerInfoDTO;
import com.ktgj.customer.domain.vo.CustomerResource;
import com.ktgj.customer.domain.vo.SaveDistributeVo;
import com.ktgj.customer.mapper.*;
import com.ktgj.customer.service.IEmployeePositionService;
import com.ktgj.customer.service.IPositionService;
import com.ktgj.customer.service.ILoginService;
import com.ktgj.sms.api.RemoteSmsService;
import com.ktgj.sms.api.domain.Sms;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktgj.customer.service.IEmployeeService;

import static com.ktgj.customer.service.impl.LoginServiceImpl.EMPLOYEE_LOGIN_TOKEN_KEY;

/**
 * 员工Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-27
 */
@Service
public class EmployeeServiceImpl implements IEmployeeService 
{
    @Autowired
    private EmployeeMapper employeeMapper;
    @Autowired
    private RemoteSmsService remoteSmsService;
    @Autowired
    private CustomerMapper customerMapper;
    @Autowired
    private EmployeeVipresourceMapper employeeVipresourceMapper;
    @Autowired
    private SqlSessionFactory sqlSessionFactory;
    @Autowired
    private IEmployeePositionService employeePositionService;
    @Autowired
    private DepartmentMapper departmentMapper;
    @Autowired
    private ILoginService loginService;
    @Autowired
    private IPositionService positionService;
    @Autowired
    private RedisService redisService;
    @Autowired
    private DepositBusinessMapper depositBusinessMapper;

    /**
     * 查询员工
     * 
     * @param employeeId 员工ID
     * @return 员工
     */
    @Override
    public Employee selectEmployeeById(Long employeeId)
    {
        return employeeMapper.selectEmployeeById(employeeId);
    }

    /**
     * 查询员工列表
     * 
     * @param employee 员工
     * @return 员工
     */
    @Override
    public List<Employee> selectEmployeeList(Employee employee) {
        List<Employee> employeeList = employeeMapper.selectEmployeeList(employee);
        if (employeeList != null && employeeList.size() > 0){
            List<Position> positionList = positionService.queryPositionList();
            for (int i = 0; i < employeeList.size(); i++) {
                Long resourceCount = employeeVipresourceMapper.employeeVipCount(employeeList.get(i).getEmployeeId());
                employeeList.get(i).setResourceNum(resourceCount);
                EmployeePosition position = new EmployeePosition();
                position.setEmployeeId(employeeList.get(i).getEmployeeId());
                List<EmployeePosition> positions = employeePositionService.selectEmployeePositionList(position);
                if (positions != null && positions.size() > 0) {
                    int finalI = i;
                    positionList.forEach(items -> {
                        positions.forEach(item -> {
                            if (item.getPositionId().equals(items.getPositionId())) {
                                EmployeePosition employeePosition = new EmployeePosition();
                                employeePosition.setId(item.getId());
                                employeePosition.setEmployeeId(item.getEmployeeId());
                                employeePosition.setPositionId(item.getPositionId());
                                employeePosition.setPositionName(items.getPositionName());
                                employeeList.get(finalI).getEmployeePositions().add(employeePosition);
                            }
                        });
                    });
                }
            }
        }
        return employeeList;
    }

    /**
     * 新增员工
     * 
     * @param employeeList 员工
     * @return 结果
     */
    @Override
    public int insertEmployee(List<Employee> employeeList) throws Exception {
        for (Employee employee : employeeList) {
            employee.setEmployeeStatus(CustomerConstants.induction.getValue());
            employee.setEmployeeLoginPwd(DigestUtils.md5Hex(employee.getEmployeeLoginPwd()));
            int i = employeeMapper.insertEmployee(employee);
            if (i <= 0){
                throw new Exception("添加失败");
            }
            if (employee.getEmployeePositions() != null && employee.getEmployeePositions().size() > 0) {
                employee.getEmployeePositions().forEach(item -> {
                    EmployeePosition position = new EmployeePosition();
                    position.setEmployeeId(employee.getEmployeeId());
                    position.setPositionId(item.getPositionId());
                    employeePositionService.insertEmployeePosition(position);
                });
            }

        }
        return 1;
    }

    /**
     * 修改员工
     * 
     * @param employeeList 员工集合
     * @return 结果
     */
    @Override
    public int updateEmployee(List<Employee> employeeList) throws Exception {
        if (employeeList != null && employeeList.size() > 0){
            for (Employee employee : employeeList) {
                EmployeePosition position = new EmployeePosition();
                position.setEmployeeId(employee.getEmployeeId());
                List<EmployeePosition> positionList = employeePositionService.selectEmployeePositionList(position);
//                employee.setEmployeeLoginPwd(DigestUtils.md5Hex(employee.getEmployeeLoginPwd()));
                int i = employeeMapper.updateEmployee(employee);
                if (i <= 0){
                    throw new Exception("修改失败" + employee.getEmployeeId());
                }
                positionList.forEach(positions -> {
                    employeePositionService.deleteEmployeePositionById(positions.getId());
                });
                employee.getEmployeePositions().forEach(positions -> {
                    position.setPositionId(positions.getPositionId());
                    employeePositionService.insertEmployeePosition(position);
                });

                /*if (positionList.size() == employee.getEmployeePositions().size()) {
                    for (int j = 0; j < employee.getEmployeePositions().size(); j++) {
                        position = new EmployeePosition();
                        position.setId(positionList.get(j).getId());
                        position.setEmployeeId(employee.getEmployeeId());
                        position.setPositionId(employee.getEmployeePositions().get(j).getPositionId());
                        employeePositionService.updateEmployeePosition(position);
                    }
                } else if (positionList.size() < employee.getEmployeePositions().size()) {
                    for (int k = 0; k < positionList.size(); k++) {
                        position = new EmployeePosition();
                        position.setId(positionList.get(k).getId());
                        position.setEmployeeId(employee.getEmployeeId());
                        position.setPositionId(employee.getEmployeePositions().get(k).getPositionId());
                        employeePositionService.updateEmployeePosition(position);
                    }
                    for (int x = 0; x < employee.getEmployeePositions().size() - positionList.size(); x++) {
                        position = new EmployeePosition();
                        position.setEmployeeId(employee.getEmployeeId());
                        position.setPositionId(employee.getEmployeePositions().get(positionList.size()).getPositionId());
                        employeePositionService.insertEmployeePosition(position);
                    }
                } else if (positionList.size() > employee.getEmployeePositions().size()) {
                    for (int y = 0; y < employee.getEmployeePositions().size(); y++) {
                        position = new EmployeePosition();
                        position.setId(positionList.get(y).getId());
                        position.setEmployeeId(employee.getEmployeeId());
                        position.setPositionId(employee.getEmployeePositions().get(y).getPositionId());
                        employeePositionService.updateEmployeePosition(position);
                    }
                    for (int z = 0; z < positionList.size() - employee.getEmployeePositions().size(); z++) {
                        employeePositionService.deleteEmployeePositionById(positionList.get(employee.getEmployeePositions().size()).getId());
                    }
                }*/
            }
            return 1;
        }
        else {
            throw new Exception("缺少参数");
        }
    }

    /**
     * 批量删除员工
     * 
     * @param employeeIds 需要删除的员工ID
     * @return 结果
     */
    @Override
    public int deleteEmployeeByIds(Long[] employeeIds)
    {
        return employeeMapper.deleteEmployeeByIds(employeeIds);
    }

    /**
     * 删除员工信息
     * 
     * @param employeeId 员工ID
     * @return 结果
     */
    @Override
    public int deleteEmployeeById(Long employeeId)
    {
        return employeeMapper.deleteEmployeeById(employeeId);
    }

    @Override
    public boolean resetEmployeePassword(Long employeeId)
    {
        Employee employee = employeeMapper.selectEmployeeById(employeeId);
        String randomNumber = RandomUtil.randomNumbers(6);
        employee.setEmployeeLoginPwd(DigestUtils.md5Hex(randomNumber));
        Sms resetMessage = new Sms();
        resetMessage.setMobile(employee.getEmployeeMobile());
        resetMessage.setSendTime(DateUtils.getNowDate());
        resetMessage.setSmsContent("金色世纪员工" + employee.getEmployeeLoginId() + "密码重置为" + randomNumber + "请用新密码登录系统！申请密码重置时间为" + DateUtils.getNowDate());
        boolean isSend = remoteSmsService.sendSmsMessage(resetMessage);
        int rows = employeeMapper.updateEmployee(employee);
        if (isSend && rows > 0)
        {
            return true;
        }
        return false;
    }

    @Override
    public int quit(Long employeeId) {
        String status = employeeMapper.selectEmployeeStatusById(employeeId);
        Employee employee = new Employee();
        employee.setEmployeeId(employeeId);
        if (status.equals(CustomerConstants.induction.getValue()))
            employee.setEmployeeStatus(CustomerConstants.quit.getValue());
        else
            employee.setEmployeeStatus(CustomerConstants.induction.getValue());
        return employeeMapper.updateEmployee(employee);
    }

    /**
     * 新增vip经理
     * */
//    @Override
//    public int addvipManager(Employee employee) {
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//        List<Customer> customers = customerMapper.selectCustomerByList();
//        List<Long> customerIdList = new ArrayList<>();
//        for (Customer customer : customers) {
//            List<EmployeeVipresource> employeeVipresource = employeeVipresourceMapper.selectEmployeeVipresourcebyId(customer.getCustomerId());
//            if (employeeVipresource == null && employeeVipresource.size() > 0){
//                customerIdList.add(customer.getCustomerId());
//            }
//        }
//        Employee employee1 = employeeMapper.selectEmployeeByEmployeeLoginId(employee);
//        int i = employeeMapper.addvipManager(employee1);
//
//        Date date;
//        try {
//            date = format.parse(format.format(new Date()));
//        } catch (Exception e){
//            return 0;
//        }
//
////        for (Long aLong : customerIdList) {
////            employeeVipresourceMapper.insertEmployeeVipresource(aLong, date, date, employee1.getEmployeeId(), employee1.getEmployeeId());
////        }
//
//        return i;
//    }

    /**
     * 转移
     * */
//    @Override
//    public int updateEmployeeVipresource(EmployeeVipresource employeeVipresource) {
//        List<EmployeeVipresource> employeeVipresources = employeeVipresourceMapper.selectEmployeeVipresource(employeeVipresource.getVipresourceId());
//        if (employeeVipresources.size() < employeeVipresource.getEmployeeNum()){
//            employeeVipresource.setEmployeeNum(employeeVipresources.size());
//        }
//        try {
//            for (int i = 0 ; i < employeeVipresource.getEmployeeNum() ; i++) {
//                employeeVipresourceMapper.updateEmployeeVipresource(employeeVipresources.get(i).getCustomerId(), employeeVipresource.getEmployeeId());
//            }
//            return 1;
//        } catch (Exception e){
//            return 0;
//        }
//    }

    /**
     * 分配
     * */
//    @Override
//    public int distribute(Long employeeId) {
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//        List<EmployeeVipresource> employeeVipresourceList = employeeVipresourceMapper.EmployeeVipresourceList();//员工资源数组里的会员ID
//        List<Long> idList = new ArrayList<>();//会员id集合
//        for (EmployeeVipresource employeeVipresource : employeeVipresourceList) {
//            idList.add(employeeVipresource.getCustomerId());
//        }
//
//        List<Customer> customers = customerMapper.randomCustomer(idList);//会员集合
//
//        List<Customer> customerList = new ArrayList<>();
//        List<Long> customerIdList = new ArrayList<>();
//        // todo 测试用
//        for (int i = 0 ; i < customers.size() ; i++) {
////        for (int i = 0 ; i < 1000 ; i++) {
//            for (Long aLong : idList) {
//                if (customers.get(i).getCustomerId() != aLong){
//                    customerIdList.add(customers.get(i).getCustomerId());
//                }
//            }
//
//            HashSet hashSet = new HashSet(customerIdList);
//            customerIdList.clear();
//            customerIdList.addAll(hashSet);
//        }
//
//        for (Long aLong : customerIdList) {
//            Customer customer = customerMapper.selectCustomerById(aLong);
//            customerList.add(customer);
//        }
//
//        customers = customerList;
//
//        Date date;
//        try {
//            date = format.parse(format.format(new Date()));
//        } catch (Exception e){
//            return 0;
//        }
//
//        try {
//            for (Customer customer : customers) {
//                employeeVipresourceMapper.insertEmployeeVipresource(customer.getCustomerId(), date, date, employeeId, employeeId);
//            }
//            return 1;
//        } catch (Exception e){
//            return 0;
//        }
//    }
    /**
     * 查询一个员工关联着几个会员
     * @param employee
     * @return
     */
    @Override
    public List<Employee> selectEmployeeVipList(Employee employee) {
        List<Employee> list=new ArrayList<>();
        List<Employee>lis=employeeMapper.selectEmployeeList(employee);
        for (Employee emp:lis) {
            emp.setResourceNum(employeeMapper.selectEmpVipCount(emp.getEmployeeId()));
            list.add(emp);
        }
        return list;
    }
    /**
     * 查询VIP经理手下的会员明细
     * */

//    @Override
//    public List<EmployeeVipresource> selectEmployeeVipresourceList(Long employeeId) {
//        return employeeVipresourceMapper.selectEmployeeVipresourceList(employeeId);
//    }
    /**
     * 查询员工列表（是VIP经理且在职）
     */
    @Override
    public List<Employee> selectEmployeeVip(Long deptId) {
        return employeeMapper.selectEmployeeVip(deptId);
    }

//    @Override
//    public boolean distributeCustomerInfo(Long employeeId, List<CustomerCardGroupVO> lstCustomerInfo)
//    {
//        int rows = employeeVipresourceMapper.deleteEmployeeResourceById(employeeId);
//        if (rows > 0)
//        {
//            SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
//            EmployeeVipresourceMapper employeeVipresourceMapper = sqlSession.getMapper(EmployeeVipresourceMapper.class);
//            for (CustomerCardGroupVO customerCardGroupVO: lstCustomerInfo)
//            {
//                for (CustomerInfoDTO customerInfoDTO: customerCardGroupVO.getLstCustomerInfo())
//                {
//                    employeeVipresourceMapper.insertEmployeeVipresource(customerInfoDTO.getCustomerId(),customerInfoDTO.getCreateTime(),DateUtils.getNowDate(),employeeId,employeeId);
//                }
//            }
//            sqlSession.commit();
//            sqlSession.clearCache();
//            return true;
//        } else
//        {
//            return false;
//        }
//    }

    /**
     * 员工姓名获取id
     * */
    @Override
    public List<Long> employeeIdList(String name) {
        List<Employee> employeeList = employeeMapper.employeeIdList(name);
        if (employeeList != null && employeeList.size() > 0){
            List<Long> longList = new ArrayList<>();
            for (Employee employee : employeeList) {
                longList.add(employee.getEmployeeId());
            }
            return longList;
        }
        return null;
    }

    /**
     * 员工id获取姓名
     * */
    @Override
    public Employee employeeNameList(Long id) {
        Employee employee = employeeMapper.employeeNameList(id);
        return employee;
    }

    /**
     * 获取指定部门的所有员工id
     * */
    @Override
    public List<Long> employeeVipIdList(Long deptId) {
        List<Long> idList = new ArrayList<>();
        List<Employee> employeeList = employeeMapper.employeeVipIdList(deptId);
        if (employeeList != null && employeeList.size() > 0){
            for (Employee employee : employeeList) {
                idList.add(employee.getEmployeeId());
            }
        }
        return idList;
    }

    @Override
    public List<Employee> getEmployeeListByIds(List<Long> lstIds)
    {
        return employeeMapper.selectEmployeeByIds(lstIds);
    }

    /**
     * 保存vip经理分配信息
     * */
    @Override
    public boolean saveDistribute(Employee employee, SaveDistributeVo saveDistributeVo)
    {
        try
        {
//            Date date = new Date();
//            List<CustomerInfoDTO> lstCustomerDTO = customerMapper.getCustomerCardInfo(saveDistributeVo);
//            for (CustomerInfoDTO customerInfoDTO : lstCustomerDTO)
//            {
//                Long id = employeeVipresourceMapper.checkCustomerIdExist(customerInfoDTO.getCustomerId());
//                if (id == null)
//                {
//                    EmployeeVipresource employeeVipresource = new EmployeeVipresource();
//                    employeeVipresource.setCustomerId(customerInfoDTO.getCustomerId());
//                    employeeVipresource.setRegiesttime(customerInfoDTO.getCreateTime());
//                    employeeVipresource.setCreattime(date);
//                    employeeVipresource.setCreatepersonid(employee.getEmployeeId());
//                    employeeVipresource.setEmployeeId(saveDistributeVo.getEmployeeId());
//                    employeeVipresource.setUpdateTime(date);
//                    employeeVipresource.setUpdatepersonid(employee.getEmployeeId());
//                    employeeVipresource.setCustomerName(customerInfoDTO.getCustomerName());
//                    employeeVipresource.setCustomerPhone(customerInfoDTO.getPhone());
//                    employeeVipresourceMapper.insertEmployeeVipresource(employeeVipresource);
//                }
//            }
        }catch (Exception e)
        {
            return false;
        }
        return true;

//        Long id = employeeVipresourceMapper.checkCustomerIdExist(20l);
//        Long count = employeeVipresourceMapper.getEmployeeVipCount(100l);
//        if (saveDistributeVo.getCustomerIdList() != null && saveDistributeVo.getCustomerIdList().size() > 0){
//            List<Customer> lstCustomer = new ArrayList<>();
//            List<EmployeeVipresource> lstResource = new ArrayList<>();
//            for (Long aLong : saveDistributeVo.getCustomerIdList()) {
//                Customer customer = customerMapper.InquireCustomerById(aLong);
//                if (customer == null){
//                    throw new Exception("无效的会员id:" + aLong);
//                }
//                lstCustomer.add(customer);
//                EmployeeVipresource employeeVipresource = new EmployeeVipresource();
//                employeeVipresource.setCustomerId(aLong);
//                employeeVipresource.setRegiestTime(customer.getCreateTime());
//                employeeVipresource.setCreatTime(date);
//                employeeVipresource.setCratePersonId(employee.getEmployeeId());
//                employeeVipresource.setEmployeeId(saveDistributeVo.getEmployeeId());
//                employeeVipresource.setUpdateTime(date);
//                employeeVipresource.setUpdatePersonId(employee.getEmployeeId());
//                int i = employeeVipresourceMapper.saveDistribute(employeeVipresource);
//                if (i <= 0){
//                    throw new Exception("资源分配失败id:" + aLong);
//                }
//            }
//            for (Customer customer : lstCustomer)
//            {
//                EmployeeVipresource employeeVipresource = new EmployeeVipresource();
//                employeeVipresource.setCustomerId(customer.getCustomerId());
//                employeeVipresource.setRegiestTime(customer.getCreateTime());
//                employeeVipresource.setCreatTime(date);
//                employeeVipresource.setCratePersonId(employee.getEmployeeId());
//                employeeVipresource.setEmployeeId(saveDistributeVo.getEmployeeId());
//                employeeVipresource.setUpdateTime(date);
//                employeeVipresource.setUpdatePersonId(employee.getEmployeeId());
//                lstResource.add(employeeVipresource);
//            }
//            return 1;
//        }
//        else {
//            throw new Exception("缺少必要参数");
//        }
    }

    @Override
    public List<Employee> getOnlineEmployeeList() {
        List<Employee> lstOnlineEmployee = new ArrayList<>();
        Collection<String> keys = redisService.keys(EMPLOYEE_LOGIN_TOKEN_KEY + "*");
        for (String key : keys) {
            String employeeJson = redisService.getCacheObject(key);
            Employee employeeLogin = JSONObject.parseObject(employeeJson, Employee.class);
            lstOnlineEmployee.add(employeeLogin);
        }
        return lstOnlineEmployee;
    }

    @Override
    public boolean changeVipresource(Long sourceId, Long targetId, Long customerId)
    {
        if (customerId != null)
        {
            EmployeeVipresource queryEmployeeVip = new EmployeeVipresource();
            queryEmployeeVip.setCustomerId(customerId);
            queryEmployeeVip.setEmployeeId(sourceId);
            List<EmployeeVipresource> lstEmployeeVip = employeeVipresourceMapper.selectEmployeeVipresourceList(queryEmployeeVip);
            EmployeeVipresource tmpEmployee = lstEmployeeVip.get(0);
            tmpEmployee.setEmployeeId(targetId);
            int result = employeeVipresourceMapper.updateEmployeeVipresource(tmpEmployee);
            if (result > 0)
            {
                return true;
            }
            return false;
        }
        int result = employeeVipresourceMapper.changeVipresource(sourceId, targetId);
        if (result > 0)
        {
            return true;
        }
        return false;
    }

    @Override
    public List<CustomerInfoDTO> getCustomerResource(CustomerResource customerResource) {
        List<CustomerInfoDTO> lstCustomerDTO = customerMapper.getCustomerCardInfo(customerResource);
        List<CustomerInfoDTO> lstTmpCustomer = new ArrayList<>();
        if (customerResource.getIsDeposit() != null && !StringHelper.isNullOrEmpty(customerResource.getIsDeposit())) {
            if (customerResource.getIsDeposit().equals("true")) {
                for (CustomerInfoDTO customerInfoDTO : lstCustomerDTO) {
                    List<BigDecimal> lstAmount = depositBusinessMapper.queryUseDepositBusiness(customerInfoDTO.getCustomerId());
                    if (lstAmount.size() > 0) {
                        lstTmpCustomer.add(customerInfoDTO);
                    }
                }
            } else {
                for (CustomerInfoDTO customerInfoDTO : lstCustomerDTO) {
                    List<BigDecimal> lstAmount = depositBusinessMapper.queryUseDepositBusiness(customerInfoDTO.getCustomerId());
                    if (lstAmount.size() == 0) {
                        lstTmpCustomer.add(customerInfoDTO);
                    }
                }
            }
        }
        if (customerResource.getIsMember() != null && !StringHelper.isNullOrEmpty(customerResource.getIsMember())) {
            if (lstTmpCustomer.size() > 0) {
                List<CustomerInfoDTO> lstTmpMember = null;
                if (customerResource.getIsMember().equals("true")) {
                    lstTmpMember = lstTmpCustomer.stream().filter(item -> item.getLstCustomerCardInfo().size() > 1).collect(Collectors.toList());
                } else {
                    lstTmpMember = lstTmpCustomer.stream().filter(item -> item.getLstCustomerCardInfo().size() == 1).collect(Collectors.toList());
                }
                lstTmpCustomer = lstTmpMember;
            } else {
                if (customerResource.getIsMember().equals("true")) {
                    lstTmpCustomer = lstCustomerDTO.stream().filter(item -> item.getLstCustomerCardInfo().size() > 1).collect(Collectors.toList());
                } else {
                    lstTmpCustomer = lstCustomerDTO.stream().filter(item -> item.getLstCustomerCardInfo().size() == 1).collect(Collectors.toList());
                }
            }
        }
        if (lstTmpCustomer.size() > 0) {
            return lstTmpCustomer;
        }
        return lstCustomerDTO;
    }

    @Override
    public boolean distributeCustomer(Employee employee, List<CustomerInfoDTO> lstCustomer)
    {
        try
        {
            Date date = new Date();
            for (CustomerInfoDTO customerInfoDTO : lstCustomer)
            {
                Long id = employeeVipresourceMapper.checkCustomerIdExist(customerInfoDTO.getCustomerId());
                if (id == null)
                {
                    EmployeeVipresource employeeVipresource = new EmployeeVipresource();
                    employeeVipresource.setCustomerId(customerInfoDTO.getCustomerId());
                    employeeVipresource.setRegiesttime(customerInfoDTO.getCreateTime());
                    employeeVipresource.setCreattime(date);
                    employeeVipresource.setCreatepersonid(employee.getEmployeeId());
                    employeeVipresource.setEmployeeId(customerInfoDTO.getEmployeeId());
                    employeeVipresource.setUpdatetime(date);
                    employeeVipresource.setUpdatepersonid(employee.getEmployeeId());
                    employeeVipresource.setCustomerName(customerInfoDTO.getCustomerName());
                    employeeVipresource.setCustomerPhone(customerInfoDTO.getPhone());
                    employeeVipresource.setDistributeTime(DateUtils.getNowDate());
                    employeeVipresourceMapper.insertEmployeeVipresource(employeeVipresource);
                }
            }
            return true;
        } catch (Exception e)
        {
            return false;
        }
    }
}
